home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / AmigaTalk_X / system / PrinterDevice.st < prev    next >
Encoding:
Text File  |  2002-03-13  |  27.0 KB  |  730 lines

  1. " ------------------------------------------------------------------- "
  2. " Printer Class is a class for controlling the printer device.        "
  3. ""
  4. " If any 'Send' method seems to hang the System, either Ctrl-C or     "
  5. " Ctrl-D should break the I/O hangup.                                 "
  6. ""
  7. "  WARNING:  You should know what you're doing to the Amiga OS before "
  8. "            messing with this Class, or any other System Class!      "
  9. ""
  10. " If your printer does not support a method, AmigaTalk might display  "
  11. " a Requester stating that the printer.device failed to open, because "
  12. " the Error code returned by the printer.device is brain-damaged.     "
  13. " ------------------------------------------------------------------- "
  14.  
  15. Class PrinterDevice :Device ! private !
  16. [
  17.    initialize: initString
  18.      " Send an initialization string to the printer.device. " 
  19.      <primitive 225 2 private initString>
  20. |
  21.    getPrinterClassString
  22.      ^ <primitive 225 19>
  23. |
  24.    getPrinterColorClassString 
  25.      ^ <primitive 225 20>
  26. |
  27.    getPrinterName 
  28.      ^ <primitive 225 21>
  29. |
  30.    getNumberOfCharSets
  31.      ^ <primitive 225 22>
  32. |
  33.    getHorizontalDPI 
  34.      ^ <primitive 225 23>
  35. |
  36.    getVerticalDPI 
  37.      ^ <primitive 225 24>
  38. |
  39.    getNumberOfPrintColumns 
  40.      ^ <primitive 225 25>
  41. |
  42.    getNumberOfHeadPins 
  43.      ^ <primitive 225 26>
  44. |
  45.    getMaxXRasterDump 
  46.      ^ <primitive 225 27>
  47. |
  48.    getMaxYRasterDump 
  49.      ^ <primitive 225 28>
  50. |
  51.    reset
  52.      " Send CMD_RESET to printer.device. "
  53.      <primitive 225 9 private>
  54. |
  55.    sendExtendedCmd: command parm1: p1 parm2: p2 parm3: p3 parm4: p4
  56.      " Send an extended command to the printer.device. 
  57.      * See PrtCommands class below.
  58.      "
  59.      <primitive 225 6 private command p1 p2 p3 p4>
  60. |
  61.    restart
  62.      " Send CMD_START to the printer.device. "
  63.      <primitive 225 10 private>
  64. |
  65.    stop
  66.      " Send CMD_STOP to the printer.device. "
  67.      <primitive 225 11 private>
  68. |
  69.    flush
  70.      " Send CMD_FLUSH to the printer.device. "
  71.      <primitive 225 8 private>
  72. |
  73.    query
  74.      " Ask the printer.device to return two bytes of status (PRD_QUERY)
  75.      * as a two-byte String.  The String might have non-displayable values!
  76.      "
  77.      ^ <primitive 225 5 private>
  78. |
  79.    dumpGraphics: specialArray ! rpObj cm modeID xOffset yOffset w h dc dr flags !
  80.      " Send PRD_DUMPRPORT to the printer.device in order to print a screen
  81.      * dump.
  82.      *
  83.      * The parameters needed in specialArray are as follows:
  84.      *
  85.      *   rpObj   = raster port,        struct RastPort *
  86.      *   cm      = color map,          struct ColorMap *
  87.      *   modeID  = screenModeID,       ULONG
  88.      *   xOffset = source x origin,    UWORD
  89.      *   yOffset = source y origin,    UWORD
  90.      *   w       = source width,       UWORD
  91.      *   h       = source height,      UWORD
  92.      *   dc      = destination width,  LONG
  93.      *   dr      = destination height, LONG
  94.      *   flags   = option flags,       UWORD
  95.      "
  96.      rpObj   <- specialArray at: 1.
  97.      cm      <- specialArray at: 2.
  98.      modeID  <- specialArray at: 3.
  99.      xOffset <- specialArray at: 4.
  100.      yOffset <- specialArray at: 5.
  101.      w       <- specialArray at: 6.
  102.      h       <- specialArray at: 7.
  103.      dc      <- specialArray at: 8.
  104.      dr      <- specialArray at: 9.
  105.      flags   <- specialArray at: 10. "See PrtRPFlags class below."
  106.  
  107.      <primitive 225 12 private rpObj cm modeID xOffset yOffset w h dc dr flags>
  108. |
  109.    readPrinterPrefsInto: aBuffer ofSize: length
  110.      " If the read fails because the buffer is too small you should double
  111.      * the size of the buffer and try it again.
  112.      *
  113.      * Never interpret the contents of the buffer. You are allowed to save
  114.      * it to file (as one block of data) and of course to write it back to
  115.      * the driver (writePrinterPrefs).
  116.      *
  117.      * If you close the printer device between PRD_EDITPREFS and the
  118.      * actual printing (CMD_WRITE or PRD_DUMPRPORTTAGS) you must read
  119.      * the prefs after PRD_EDITPREFS and write it back before printing
  120.      * or the driver may forget the user changes.
  121.      "
  122.      ^ <primitive 225 14 private aBuffer length> 
  123. |
  124.    writePrinterPrefsFrom: aBuffer ofSize: length
  125.      " This is a non standard write command that writes the driver 
  126.      * preferences.  The printer driver checks the buffer before 
  127.      * copying it to its preferences.  So you do not have to worry 
  128.      * about changing the printer driver between readPrinterPrefsInto:ofSize:
  129.      * and this method.
  130.      "
  131.      ^ <primitive 225 15 private aBuffer length>
  132. |
  133.    editPrinterPrefs: tagArray
  134.      " New drivers can have their own preferences.  This method asks the driver
  135.      * to open a window to allow the user to change the prefs.
  136.      *
  137.      * Every application should have a button 'Driver Options...' (that
  138.      * calls this method in its printer dialog.
  139.      "
  140.      ^ <primitive 225 16 private tagArray>
  141. |
  142.    setPrinterErrorHook: hookObject
  143.      " This command sets a hook that will be called if the printer.device
  144.      * returns with an error from any other I/O command.  This allows
  145.      * printer drivers to use private error messages.
  146.      "
  147.      ^ <primitive 225 17 private hookObject> 
  148. |
  149.    dumpTaggedGraphics: specialArray ! rpObj cm modeID xOffset yOffset w h dc dr flags tags !
  150.      " Send PRD_DUMPRPORTTAGS to the printer.device in order to print a screen
  151.      * dump.
  152.      *
  153.      * The parameters needed in specialArray are as follows:
  154.      *
  155.      *   rpObj   = raster port,        struct RastPort *
  156.      *   cm      = color map,          struct ColorMap *
  157.      *   modeID  = screenModeID,       ULONG
  158.      *   xOffset = source x origin,    UWORD
  159.      *   yOffset = source y origin,    UWORD
  160.      *   w       = source width,       UWORD
  161.      *   h       = source height,      UWORD
  162.      *   dc      = destination width,  LONG
  163.      *   dr      = destination height, LONG
  164.      *   flags   = option flags,       UWORD
  165.      *   tags    = tagList             struct TagItem * 
  166.      "
  167.      rpObj   <- specialArray at: 1.
  168.      cm      <- specialArray at: 2.
  169.      modeID  <- specialArray at: 3.
  170.      xOffset <- specialArray at: 4.
  171.      yOffset <- specialArray at: 5.
  172.      w       <- specialArray at: 6.
  173.      h       <- specialArray at: 7.
  174.      dc      <- specialArray at: 8.
  175.      dr      <- specialArray at: 9.
  176.      flags   <- specialArray at: 10. "See PrtRPFlags class below."
  177.      tags    <- specialArray at: 11.
  178.      
  179.      <primitive 225 13 private rpObj cm modeID xOffset yOffset w h dc dr flags tags>
  180. |
  181.    getPrinterErrorString
  182.      " Return a String that describes the last Printer Error Number found. "
  183.      ^ <primitive 225 18 private> 
  184. |
  185.    close
  186.      " Close the printer.device & remove it from AmigaTalk program space. " 
  187.      <primitive 225 0 private>
  188. |
  189.    open: printerName
  190.      " Allocate the internal memory & structures needed for opening
  191.      * the printer.device.  Return an Integer Object.
  192.      " 
  193.      private <- <primitive 225 1 printerName>
  194. |
  195.    sendRawWrite: buffer ofLength: length
  196.      " Send a Raw buffer of data to the printer.device. "
  197.      <primitive 225 7 private buffer length>
  198. |
  199.    write: thisString ofLength: length
  200.      " Write a string length bytes long to the printer.device. "
  201.      ^ <primitive 225 3 private thisString length>
  202. |
  203.    asyncWrite: thisString ofLength: length
  204.      " Write a string length bytes long to the printer.device 
  205.      * with asynchronous I/O.
  206.      "
  207.      ^ <primitive 225 4 private thisString length>
  208. |
  209.    " SHORTCUTS FOR COMMON PRINTER COMMANDS: "
  210.  
  211.    crlf ! prtCmds crlfCode !
  212.      prtCmds  <- PrtCommands new.
  213.      crlfCode <- prtCmds at: #aNEL.
  214.  
  215.      " Send a Carriage Return-LineFeed command code to the Printer:"
  216.      <primitive 225 6 private crlfCode 0 0 0 0>
  217. |
  218.    nlqOn ! prtCmds nlqOnCode !
  219.      prtCmds   <- PrtCommands new.
  220.      nlqOnCode <- prtCmds at: #aDEN2.
  221.  
  222.      " Send a Near Letter Quality ON command code to the Printer:"
  223.      <primitive 225 6 private nlqOnCode 0 0 0 0>
  224. |
  225.    nlqOff ! prtCmds nlqOffCode !
  226.      prtCmds   <- PrtCommands new.
  227.      nlqOffCode <- prtCmds at: #aDEN1.
  228.  
  229.      " Send a Near Letter Quality OFF command code to the Printer:"
  230.      <primitive 225 6 private nlqOffCode 0 0 0 0>
  231. |
  232.    normalCharSet ! prtCmds normCode !
  233.      prtCmds  <- PrtCommands new.
  234.      normCode <- prtCmds at: #aSGR0.
  235.  
  236.      " Send a Normal Character Set command code to the Printer:"
  237.      <primitive 225 6 private normCode 0 0 0 0>
  238. |
  239.    italicsOn ! prtCmds italicOnCode !
  240.      prtCmds      <- PrtCommands new.
  241.      italicOnCode <- prtCmds at: #aSGR3.
  242.  
  243.      " Send an Italics ON command code to the Printer:"
  244.      <primitive 225 6 private italicOnCode 0 0 0 0>
  245. |
  246.    italicsOff ! prtCmds italicOffCode !
  247.      prtCmds       <- PrtCommands new.
  248.      italicOffCode <- prtCmds at: #aSGR23.
  249.  
  250.      " Send an Italics OFF command code to the Printer:"
  251.      <primitive 225 6 private italicOffCode 0 0 0 0>
  252. |
  253.    underlineOn ! prtCmds underOnCode !
  254.      prtCmds     <- PrtCommands new.
  255.      underOnCode <- prtCmds at: #aSGR4.
  256.  
  257.      " Send an Underline ON command code to the Printer:"
  258.      <primitive 225 6 private underOnCode 0 0 0 0>
  259. |
  260.    underlineOff ! prtCmds underOffCode !
  261.      prtCmds      <- PrtCommands new.
  262.      underOffCode <- prtCmds at: #aSGR24.
  263.  
  264.      " Send an Underline OFF command code to the Printer:"
  265.      <primitive 225 6 private underOffCode 0 0 0 0>
  266. |
  267.    boldOn ! prtCmds boldOnCode !
  268.      prtCmds    <- PrtCommands new.
  269.      boldOnCode <- prtCmds at: #aSGR1.
  270.  
  271.      " Send an BoldFace ON command code to the Printer:"
  272.      <primitive 225 6 private boldOnCode 0 0 0 0>
  273. |
  274.    boldOff ! prtCmds boldOffCode !
  275.      prtCmds     <- PrtCommands new.
  276.      boldOffCode <- prtCmds at: #aSGR22.
  277.  
  278.      " Send an BoldFace OFF command code to the Printer:"
  279.      <primitive 225 6 private boldOffCode 0 0 0 0>
  280. |
  281.    normalPitch ! prtCmds normalCode !
  282.      prtCmds    <- PrtCommands new.
  283.      normalCode <- prtCmds at: #aSHORP0.
  284.  
  285.      " Send an Normal Pitch command code to the Printer:"
  286.      <primitive 225 6 private normalCode 0 0 0 0>
  287. |
  288.    elitePitchOn ! prtCmds eliteOnCode !
  289.      prtCmds     <- PrtCommands new.
  290.      eliteOnCode <- prtCmds at: #aSHORP2.
  291.  
  292.      " Send an Elite Pitch ON command code to the Printer:"
  293.      <primitive 225 6 private eliteOnCode 0 0 0 0>
  294. |
  295.    elitePitchOff ! prtCmds eliteOffCode !
  296.      prtCmds      <- PrtCommands new.
  297.      eliteOffCode <- prtCmds at: #aSHORP1.
  298.  
  299.      " Send an Elite Pitch OFF command code to the Printer:"
  300.      <primitive 225 6 private eliteOffCode 0 0 0 0>
  301. |
  302.    condensedPitchOn ! prtCmds condensedOnCode !
  303.      prtCmds         <- PrtCommands new.
  304.      condensedOnCode <- prtCmds at: #aSHORP4.
  305.  
  306.      " Send a Condensed Fine Pitch ON command code to the Printer:"
  307.      <primitive 225 6 private condensedOnCode 0 0 0 0>
  308. |
  309.    condensedPitchOff ! prtCmds condensedOffCode !
  310.      prtCmds          <- PrtCommands new.
  311.      condensedOffCode <- prtCmds at: #aSHORP3.
  312.  
  313.      " Send a Condensed Fine Pitch OFF command code to the Printer:"
  314.      <primitive 225 6 private condensedOffCode 0 0 0 0>
  315. |
  316.    enlargedPitchOn ! prtCmds enlargedOnCode !
  317.      prtCmds        <- PrtCommands new.
  318.      enlargedOnCode <- prtCmds at: #aSHORP6.
  319.  
  320.      " Send a Enlarged Pitch ON command code to the Printer:"
  321.      <primitive 225 6 private enlargedOnCode 0 0 0 0>
  322. |
  323.    enlargedPitchOff ! prtCmds enlargedOffCode !
  324.      prtCmds         <- PrtCommands new.
  325.      enlargedOffCode <- prtCmds at: #aSHORP5.
  326.  
  327.      " Send a Enlarged Pitch OFF command code to the Printer:"
  328.      <primitive 225 6 private enlargedOffCode 0 0 0 0>
  329. |
  330.    superScriptOn ! prtCmds superOnCode !
  331.      prtCmds     <- PrtCommands new.
  332.      superOnCode <- prtCmds at: #aSUS2.
  333.  
  334.      " Send a SuperScript ON command code to the Printer:"
  335.      <primitive 225 6 private superOnCode 0 0 0 0>
  336. |
  337.    superScriptOff ! prtCmds superOffCode !
  338.      prtCmds      <- PrtCommands new.
  339.      superOffCode <- prtCmds at: #aSUS1.
  340.  
  341.      " Send a SuperScript OFF command code to the Printer:"
  342.      <primitive 225 6 private superOffCode 0 0 0 0>
  343. |
  344.    subScriptOn ! prtCmds subOnCode !
  345.      prtCmds   <- PrtCommands new.
  346.      subOnCode <- prtCmds at: #aSUS4.
  347.  
  348.      " Send a SubScript ON command code to the Printer:"
  349.      <primitive 225 6 private subOnCode 0 0 0 0>
  350. |
  351.    subScriptOff ! prtCmds subOffCode !
  352.      prtCmds    <- PrtCommands new.
  353.      subOffCode <- prtCmds at: #aSUS3.
  354.  
  355.      " Send a SubScript OFF command code to the Printer:"
  356.      <primitive 225 6 private subOffCode 0 0 0 0>
  357. |
  358.    normalizeLine ! prtCmds normCode !
  359.      prtCmds  <- PrtCommands new.
  360.      normCode <- prtCmds at: #aSUS0.
  361.  
  362.      " Send a Normalize the line (after super or sub-scripting)
  363.      * command code to the Printer:
  364.      "
  365.      <primitive 225 6 private normCode 0 0 0 0>
  366. |
  367.    partialLineUp ! prtCmds partUpCode !
  368.      prtCmds    <- PrtCommands new.
  369.      partUpCode <- prtCmds at: #aPLU.
  370.  
  371.      " Send a Partial line UP command code to the Printer:"
  372.      <primitive 225 6 private partUpCode 0 0 0 0>
  373. |
  374.    partialLineDown ! prtCmds partDnCode !
  375.      prtCmds    <- PrtCommands new.
  376.      partDnCode <- prtCmds at: #aPLD.
  377.  
  378.      " Send a Partial line DOWN command code to the Printer:"
  379.      <primitive 225 6 private partDnCode 0 0 0 0>
  380. |
  381.    setFormLength: numLines ! prtCmds formCode !
  382.      prtCmds  <- PrtCommands new.
  383.      formCode <- prtCmds at: #aSLPP.
  384.  
  385.      " Send a Set Form Length nn command code to the Printer:"
  386.      <primitive 225 6 private formCode numLines 0 0 0>
  387. |
  388.    setPerfSkip: numLines ! prtCmds perfCode !
  389.      (numLines <= 0)
  390.         ifTrue: [ ^ nil ]. " User is brain-damaged! "
  391.  
  392.      prtCmds  <- PrtCommands new.
  393.      perfCode <- prtCmds at: #aPERF.
  394.  
  395.      " Send a Set Perforation Skip nn command code to the Printer:"
  396.      <primitive 225 6 private perfCode numLines 0 0 0>
  397. |
  398.    perfSkipOff ! prtCmds perfOffCode !
  399.      prtCmds     <- PrtCommands new.
  400.      perfOffCode <- prtCmds at: #aPERF0.
  401.  
  402.      " Send a Perforation Skip OFF command code to the Printer:"
  403.      <primitive 225 6 private perfOffCode 0 0 0 0>
  404. |
  405.    setLeftMargin: numSpaces ! prtCmds leftCode !
  406.      prtCmds  <- PrtCommands new.
  407.      leftCode <- prtCmds at: #aLMS.
  408.  
  409.      " Send a Left Margin Set nn command code to the Printer:"
  410.      <primitive 225 6 private leftCode numSpaces 0 0 0>
  411. |
  412.    setRightMargin: numSpaces ! prtCmds rightCode !
  413.      prtCmds   <- PrtCommands new.
  414.      rightCode <- prtCmds at: #aRMS.
  415.  
  416.      " Send a Right Margin Set nn command code to the Printer:"
  417.      <primitive 225 6 private rightCode numSpaces 0 0 0>
  418. |
  419.    setTopMargin: numLines ! prtCmds topCode !
  420.      prtCmds <- PrtCommands new.
  421.      topCode <- prtCmds at: #aTMS.
  422.  
  423.      " Send a Top Margin Set nn command code to the Printer:"
  424.      <primitive 225 6 private topCode numLines 0 0 0>
  425. |
  426.    setBottomMargin: numLines ! prtCmds bottomCode !
  427.      prtCmds    <- PrtCommands new.
  428.      bottomCode <- prtCmds at: #aBMS.
  429.  
  430.      " Send a Bottom Margin Set nn command code to the Printer:"
  431.      <primitive 225 6 private bottomCode numLines 0 0 0>
  432. |
  433.    setTopAndBottomMargins: topLines bottom: bottomLines ! prtCmds topCode !
  434.      prtCmds <- PrtCommands new.
  435.      topCode <- prtCmds at: #aSTBM.
  436.  
  437.      " Send a Top & Bottom Margin Set nn command code to the Printer:"
  438.      <primitive 225 6 private topCode topLines bottomLines 0 0>
  439. |
  440.    setLeftAndRightMargins: leftSpcs right: rightSpcs ! prtCmds leftCode !
  441.      prtCmds  <- PrtCommands new.
  442.      leftCode <- prtCmds at: #aSLRM.
  443.  
  444.      " Send a Left & Right Margin Set nn command code to the Printer:"
  445.      <primitive 225 6 private leftCode leftSpcs rightSpcs 0 0>
  446. |
  447.    clearMargins ! prtCmds clearCode !
  448.      prtCmds   <- PrtCommands new.
  449.      clearCode <- prtCmds at: #aCAM.
  450.  
  451.      " Send a Clear Margins command code to the Printer:"
  452.      <primitive 225 6 private clearCode 0 0 0 0>
  453. |
  454.    setTabs: tab1 t2: tab2 t3: tab3 t4: tab4 ! prtCmds hTabCode !
  455.      prtCmds  <- PrtCommands new.
  456.      hTabCode <- prtCmds at: #aHTS.
  457.  
  458.      " Send a Set Horizontal Tabs command code to the Printer:"
  459.      <primitive 225 6 private hTabCode tab1 tab2 tab3 tab4>
  460. |
  461.    setTab: tab ! prtCmds hTabCode !
  462.      prtCmds  <- PrtCommands new.
  463.      hTabCode <- prtCmds at: #aHTS.
  464.  
  465.      " Send a Set Horizontal Tab nn command code to the Printer:"
  466.      <primitive 225 6 private hTabCode tab 0 0 0>
  467. |
  468.    clearTabs ! prtCmds clearCode !
  469.      prtCmds   <- PrtCommands new.
  470.      clearCode <- prtCmds at: #aTBC3.
  471.  
  472.      " Send a Clear ALL Horizontal Tabs command code to the Printer:"
  473.      <primitive 225 6 private clearCode 0 0 0 0>
  474. |
  475.    sendFormFeed ! formfeed !
  476.      formfeed <- <primitive 96 12>.
  477.  
  478.      " Send an ASCII FormFeed character (value = 12) to the Printer: "
  479.      self asyncWrite: formfeed ofLength: 1
  480. ]     
  481.  
  482. " ------------------------------------------------------------------- "
  483. " PrtRPFlags Class is a Singleton class that allows the user to       "
  484. " reference special printer flags' hexadecimal values symbolically.   "
  485. ""
  486. " ALL singleton classes MUST contain the following:                   "
  487. ""
  488. "   the methods:  isSingleton AND privateSetup     AND                "
  489. "                 uniqueInstance Class instance variable.             "
  490. " ------------------------------------------------------------------- "
  491.  
  492. Class PrtRPFlags :Dictionary ! uniqueInstance !
  493. [
  494.    isSingleton
  495.      ^ true
  496. |
  497.    privateNew ! newinstance !
  498.      newinstance <- super new.
  499.  
  500.      ^ newinstance
  501. |
  502.    new
  503.      ^ self privateSetup
  504. |
  505.    privateInitializeDictionary
  506.      "Dump RastPort to Printer flags::"
  507.  
  508.      self at: #SPECIAL_ASPECT     put: 16r80.
  509.      self at: #SPECIAL_CENTER     put: 16r40.
  510.      self at: #SPECIAL_NOFORMFEED put: 16r800.
  511.      self at: #SPECIAL_NOPRINT    put: 16r2000.
  512.      self at: #SPECIAL_TRUSTME    put: 16r1000.
  513.      self at: #SPECIAL_DENSITY1   put: 16r100.
  514.      self at: #SPECIAL_DENSITY2   put: 16r200.
  515.      self at: #SPECIAL_DENSITY3   put: 16r300.
  516.      self at: #SPECIAL_DENSITY4   put: 16r400.
  517.      self at: #SPECIAL_DENSITY5   put: 16r500.
  518.      self at: #SPECIAL_DENSITY6   put: 16r600.
  519.      self at: #SPECIAL_DENSITY7   put: 16r700.
  520.      self at: #SPECIAL_FULLCOLS   put: 4.
  521.      self at: #SPECIAL_FULLROWS   put: 8.
  522.      self at: #SPECIAL_FRACCOLS   put: 16r10.
  523.      self at: #SPECIAL_FRACROWS   put: 16r20.
  524.      self at: #SPECIAL_MILCOLS    put: 1.
  525.      self at: #SPECIAL_MILROWS    put: 2.
  526.  
  527.      " setErrorHook Symbols: "
  528.      
  529.      self at: #PDHOOK_NONE        put: 0.
  530.      self at: #PDHOOK_STD         put: 1.
  531.      
  532.      " dumpTaggedGraphics: tag Symbols: " 
  533.  
  534.      " a pointer to struct Hook which is called to read
  535.      * the source data. io_RastPort and io_ColorMap are
  536.      * ignored and should be NULL. 
  537.      *
  538.      * The hook is called with object == NULL and message
  539.      * is a pointer to struct DRPSourceMsg. It must read
  540.      * an array of source data. 
  541.      *
  542.      * Each pixel of the array is an ULONG of form 16r00RRGGBB.
  543.      *
  544.      * Some printer drivers have set PPCB_NOSTRIPE which
  545.      * means they cannot print in stripes.  Using
  546.      * DRPA_SourceHook is the best way for printing for such
  547.      * printers because you can still prepare the printer
  548.      * source data in stripes then.
  549.      *
  550.      * The Source Hook is always called in the context of
  551.      * the printer driver DOS process.     
  552.      "
  553.      self at: #DRPA_SourceHook    put: 16r80060004. "Ignores RastPort & ColorMap"
  554.  
  555.      self at: #DRPA_AspectX       put: 16r80060005. "the X aspect ratio."
  556.      
  557.      " the Y aspect ratio. This values overwrites the aspect
  558.      * ratio from GfxBase or io_Modes and is used for scaling.
  559.      "
  560.      self at: #DRPA_AspectY       put: 16r80060006.
  561.      
  562.      self at: #DRPA_ICCProfile    put: 16r80060001. " Reserved "
  563.      self at: #DRPA_ICCName       put: 16r80060002. " Reserved "
  564.      self at: #DRPA_NoColCorrect  put: 16r80060003. " Reserved "
  565.  
  566.      " editPrinterPrefs: tag Symbols: "
  567.  
  568.      " A pointer to a window.  This prefs window will open on the 
  569.      * same screen and lock the window from user input.
  570.      "
  571.      self at: #PPRA_Window        put: 16r80070001.
  572.      
  573.      " A pointer to a screen that can be used if no window is open: "
  574.      self at: #PPRA_Screen        put: 16r80070002.
  575.      
  576.      " A name of a public screen that will be used to open the window.
  577.      * This can be NULL to use the default public screen.     
  578.      "
  579.      self at: #PPRA_PubScreen     put: 16r80070003
  580. |
  581.    privateSetup
  582.      (uniqueInstance isNil)
  583.        ifTrue: [uniqueInstance <- self privateNew.
  584.  
  585.                 self privateInitializeDictionary
  586.                ].
  587.                
  588.      ^ self    "or ^ uniqueInstance??"
  589. ]
  590.  
  591. " ------------------------------------------------------------------- "
  592. " PrtCommands Class is a Singleton class that allows the user to      "
  593. " reference special printer commands' decimal values symbolically.    "
  594. ""
  595. " ALL singleton classes MUST contain the following:                   "
  596. ""
  597. "   the methods:  isSingleton AND privateSetup     AND                "
  598. "                 uniqueInstance Class instance variable.             "
  599. " ------------------------------------------------------------------- "
  600.  
  601. Class PrtCommands :Dictionary ! uniqueInstance !
  602. [
  603.    isSingleton
  604.      ^ true
  605. |
  606.    privateNew ! newinstance !
  607.      newinstance <- super new.
  608.  
  609.      ^ newinstance
  610. |
  611.    new
  612.      ^ self privateSetup
  613. |
  614.    privateInitializeDictionary
  615.      " printer command definitions: "
  616.      "                             Cmd:      Meaning:               Defined by:"
  617.                                  
  618.      self at: #aRIS    put: 0.     " ESCc      reset                  ISO "
  619.      self at: #aRIN    put: 1.  " ESC#1     initialize             AMI "
  620.      self at: #aIND    put: 2.     " ESCD      lf                     ISO "
  621.      self at: #aNEL    put: 3.     " ESCE      return,lf              ISO "
  622.      self at: #aRI    put: 4.  " ESCM      reverse lf             ISO "
  623.  
  624.      self at: #aSGR0    put: 5.  " ESC[0m    normal char set        ISO "
  625.      self at: #aSGR3    put: 6.  " ESC[3m    italics on             ISO "
  626.      self at: #aSGR23   put: 7.  " ESC[23m   italics off            ISO "
  627.      self at: #aSGR4    put: 8.  " ESC[4m    underline on           ISO "
  628.      self at: #aSGR24   put: 9.  " ESC[24m   underline off          ISO "
  629.      self at: #aSGR1    put: 10. " ESC[1m    boldface on            ISO "
  630.      self at: #aSGR22   put: 11. " ESC[22m   boldface off           ISO "
  631.      self at: #aSFC     put: 12. " SGR30-39  set foreground color   ISO "
  632.      self at: #aSBC     put: 13. " SGR40-49  set background color   ISO "
  633.  
  634.      self at: #aSHORP0  put: 14. " ESC[0w    normal pitch           DEC "
  635.      self at: #aSHORP2  put: 15. " ESC[2w    elite on               DEC "
  636.      self at: #aSHORP1  put: 16. " ESC[1w    elite off              DEC "
  637.      self at: #aSHORP4  put: 17. " ESC[4w    condensed fine on      DEC "
  638.      self at: #aSHORP3  put: 18. " ESC[3w    condensed off          DEC "
  639.      self at: #aSHORP6  put: 19. " ESC[6w    enlarged on            DEC "
  640.      self at: #aSHORP5  put: 20. " ESC[5w    enlarged off           DEC "
  641.  
  642.      self at: #aDEN6    put: 21. " ESC[6''z  shadow print on        DEC "
  643.      self at: #aDEN5    put: 22. " ESC[5''z  shadow print off       DEC "
  644.      self at: #aDEN4    put: 23. " ESC[4''z  doublestrike on        DEC "
  645.      self at: #aDEN3    put: 24. " ESC[3''z  doublestrike off       DEC "
  646.      self at: #aDEN2    put: 25. " ESC[2''z  NLQ on                 DEC "
  647.      self at: #aDEN1    put: 26. " ESC[1''z  NLQ off                DEC "
  648.  
  649.      self at: #aSUS2    put: 27. " ESC[2v    superscript on         AMI "
  650.      self at: #aSUS1    put: 28. " ESC[1v    superscript off        AMI "
  651.      self at: #aSUS4    put: 29. " ESC[4v    subscript on           AMI "
  652.      self at: #aSUS3    put: 30. " ESC[3v    subscript off          AMI "
  653.      self at: #aSUS0    put: 31. " ESC[0v    normalize the line     AMI "
  654.      self at: #aPLU     put: 32. " ESCL      partial line up        ISO "
  655.      self at: #aPLD     put: 33. " ESCK      partial line down      ISO "
  656.  
  657.      self at: #aFNT0    put: 34. " ESC(B     US char set        or Typeface  0 (default) "
  658.      self at: #aFNT1    put: 35. " ESC(R     French char set    or Typeface  1 "
  659.      self at: #aFNT2    put: 36. " ESC(K     German char set    or Typeface  2 "
  660.      self at: #aFNT3    put: 37. " ESC(A     UK char set        or Typeface  3 "
  661.      self at: #aFNT4    put: 38. " ESC(E     Danish I char set  or Typeface  4 "
  662.      self at: #aFNT5    put: 39. " ESC(H     Sweden char set    or Typeface  5 "
  663.      self at: #aFNT6    put: 40. " ESC(Y     Italian char set   or Typeface  6 "
  664.      self at: #aFNT7    put: 41. " ESC(Z     Spanish char set   or Typeface  7 "
  665.      self at: #aFNT8    put: 42. " ESC(J     Japanese char set  or Typeface  8 "
  666.      self at: #aFNT9    put: 43. " ESC(6     Norweign char set  or Typeface  9 "
  667.      self at: #aFNT10   put: 44. " ESC(C     Danish II char set or Typeface 10 "
  668.  
  669.      " Suggested typefaces are:
  670.      *
  671.      *  0 - default typeface.
  672.      *  1 - Line Printer or equiv.
  673.      *  2 - Pica or equiv.
  674.      *  3 - Elite or equiv.
  675.      *  4 - Helvetica or equiv.
  676.      *  5 - Times Roman or equiv.
  677.      *  6 - Gothic or equiv.
  678.      *  7 - Script or equiv.
  679.      *  8 - Prestige or equiv.
  680.      *  9 - Caslon or equiv.
  681.      * 10 - Orator or equiv.
  682.      "
  683.  
  684.      self at: #aPROP2   put: 45. " ESC[2p    proportional on        AMI "
  685.      self at: #aPROP1   put: 46. " ESC[1p    proportional off       AMI "
  686.      self at: #aPROP0   put: 47. " ESC[0p    proportional clear     AMI "
  687.      self at: #aTSS     put: 48. " ESC[n E  set proportional offset ISO "
  688.      self at: #aJFY5    put: 49. " ESC[5 F   auto left justify      ISO "
  689.      self at: #aJFY7    put: 50. " ESC[7 F   auto right justify     ISO "
  690.      self at: #aJFY6    put: 51. " ESC[6 F   auto full justify      ISO "
  691.      self at: #aJFY0    put: 52. " ESC[0 F   auto justify off       ISO "
  692.      self at: #aJFY3    put: 53. " ESC[3 F   letter space (justify) ISO (special) "
  693.      self at: #aJFY1    put: 54. " ESC[1 F   word fill(auto center) ISO (special) "
  694.  
  695.      self at: #aVERP0   put: 55. " ESC[0z    1/8'' line spacing     AMI "
  696.      self at: #aVERP1   put: 56. " ESC[1z    1/6'' line spacing     AMI "
  697.      self at: #aSLPP    put: 57. " ESC[nt    set form length n      DEC "
  698.      self at: #aPERF    put: 58. " ESC[nq    perf skip n (n>0)      AMI "
  699.      self at: #aPERF0   put: 59. " ESC[0q    perf skip off          AMI "
  700.  
  701.      self at: #aLMS     put: 60. " ESC#9     Left margin set        AMI "
  702.      self at: #aRMS     put: 61. " ESC#0     Right margin set       AMI "
  703.      self at: #aTMS     put: 62. " ESC#8     Top margin set         AMI "
  704.      self at: #aBMS     put: 63. " ESC#2     Bottom marg set        AMI "
  705.      self at: #aSTBM    put: 64. " ESC[Pn1;Pn2r  T&B margins        DEC "
  706.      self at: #aSLRM    put: 65. " ESC[Pn1;Pn2s  L&R margin         DEC "
  707.      self at: #aCAM     put: 66. " ESC#3     Clear margins          AMI "
  708.  
  709.      self at: #aHTS     put: 67. " ESCH      Set horiz tab          ISO "
  710.      self at: #aVTS     put: 68. " ESCJ      Set vertical tabs      ISO "
  711.      self at: #aTBC0    put: 69. " ESC[0g    Clr horiz tab          ISO "
  712.      self at: #aTBC3    put: 70. " ESC[3g    Clear all h tab        ISO "
  713.      self at: #aTBC1    put: 71. " ESC[1g    Clr vertical tabs      ISO "
  714.      self at: #aTBC4    put: 72. " ESC[4g    Clr all v tabs         ISO "
  715.      self at: #aTBCALL  put: 73. " ESC#4     Clr all h & v tabs     AMI "
  716.      self at: #aTBSALL  put: 74. " ESC#5     Set default tabs       AMI "
  717.      self at: #aEXTEND  put: 75. " ESC[Pn''x extended commands      AMI "
  718.  
  719.      self at: #aRAW     put: 76  " ESC[Pn''r Next 'Pn' chars are raw AMI "
  720. |
  721.    privateSetup
  722.      (uniqueInstance isNil)
  723.        ifTrue: [uniqueInstance <- self privateNew.
  724.  
  725.                 self privateInitializeDictionary
  726.                ].
  727.                
  728.      ^ self    "or ^ uniqueInstance??"
  729. ]
  730.